package com.holyant.goods.dto;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.annotation.Excel;
import com.holyant.goods.enums.SpecsQtyEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDate;
import java.util.Objects;

/**
 * @Author: Ssw
 * @CreateTime: 2022-11-24  09:29
 * @Description:
 */

@Data
public class NotMaintainSkuPriceExportDto {


   // @Excel(name = "渠道类型",prompt="C2P/POP/B2B-CN/B2B-HK/B2B-MO/KA/WM-C/WM-B",sort = 1)
    private String salesChannel;
    private Integer salesChannelVal;

    private Long skuId;

    @Excel(name = "sku编码")
    protected String skuCode;

    private String skuName;


    private Long goodsId;

    @Excel(name = "商品名称")
    protected String goodsName;

    @Excel(name = "商品条码")
    protected String goodsBarcode;

    private String goodsCode;


    private Long brandId;

    private String brandName;



    /** 商品效期 */
    @Excel(name = "效期" , prompt = "例:2022-09-01")
    protected LocalDate expireDate;

   // @Excel(name = "报价方式",prompt = "包邮不包税、包邮包税、不包邮不包税")
    protected String quoteMethod;
    protected Integer quoteMethodVal;

    /** 币种 */
    //@Excel(name = "币种",prompt = "人民币、港币、美金、澳元、欧元,日元")
    protected String curType;
    protected Integer curTypeVal;


   // @Excel(name = "1 pcs")
    private String pcs1;

   // @Excel(name = "2 pcs")
    private String pcs2;

  //  @Excel(name = "3 pcs")
    private String pcs3;

  //  @Excel(name = "4 pcs")
    private String pcs4;

   // @Excel(name = "5 pcs")
    private String pcs5;

   // @Excel(name = "6 pcs")
    private String pcs6;


    /** 价格json */
    @ApiModelProperty(hidden = true,name = "价格json")
    protected String priceObj;


    public String getPriceObj() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(SpecsQtyEnum.ONE.name(), getPcs1());
        jsonObject.put(SpecsQtyEnum.TWO.name(), getPcs2());
        jsonObject.put(SpecsQtyEnum.THREE.name(), getPcs3());
        jsonObject.put(SpecsQtyEnum.FOUR.name(), getPcs4());
        jsonObject.put(SpecsQtyEnum.FIVE.name(), getPcs5());
        jsonObject.put(SpecsQtyEnum.SIX.name(), getPcs6());
        return jsonObject.toString();
    }

    public void initPrice() {
        if (Objects.nonNull(priceObj)) {
            JSONObject jsonObject = JSON.parseObject(priceObj);
            for (int i = 1; i <= 6; i++) {
                SpecsQtyEnum specsQtyEnum = SpecsQtyEnum.parseByName(String.valueOf(i));
                if (i == 1 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs1(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 2 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs2(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 3 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs3(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 4 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs4(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 5 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs5(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
                if (i == 6 && null != jsonObject.getBigDecimal(specsQtyEnum.name())){
                    this.setPcs6(jsonObject.getBigDecimal(specsQtyEnum.name()).toString());
                    continue;
                }
            }
        }
    }
}
